package com.zhugang.week04;

import java.util.HashMap;
import java.util.Map;

/**
 * @program algorithms
 * @description: numWays
 * @author: chanzhugang
 * @create: 2022/06/23 21:37
 */
public class NumWays {

    /**
     * 青蛙跳台阶问题
     *
     * @param n
     * @return
     */

    Map<Integer, Integer> cache = new HashMap<>();
    int mod = 1000000007;

    public int numWays(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        if (cache.containsKey(n)) {
            return cache.get(n);
        }
        int res = (numWays(n - 1) + numWays(n - 2)) % mod;
        cache.put(n, res);
        return res;
    }
}